/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.com.wholeconsulting.pacc.gui.utils.list;

import ar.com.wholeconsulting.pacc.model.Elemento;
import ar.com.wholeconsulting.pacc.model.Modelo;
import javax.swing.DefaultListModel;

/**
 *
 * @author Duco Pablo
 */
public class ElementosListModel extends DefaultListModel {
    
    private Modelo currentModel;
    
    public ElementosListModel(Modelo currentModel) {
        this.currentModel = currentModel;
    }
    
    @Override
    public int getSize() {
        return currentModel.getElementos().size();        
    }
    
    @Override
    public Object getElementAt(int index) {
        return currentModel.getElementos().get(index);
    }
    
    @Override
    public void addElement(Object obj) {
        if (obj instanceof Elemento) {
            currentModel.getElementos().add((Elemento) obj);
        }
        
    }
}
